import { Vector3 } from './Vector3';
import { Convert } from './Convert';
export const Distance = {
    linearDistance(pointA: Vector3, pointB: Vector3): number {
        const a = Convert.lonLatToty(pointA)
        const b = Convert.lonLatToty(pointB)
        const dx = b.x - a.x;
        const dy = b.y - a.y;
        const dz = b.z - a.z;
        const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
        return distance;
    },
    sphericalDistance(pointA: Vector3, pointB: Vector3): number {
        const radius = 6378137;
        function toRadians(degrees: number): number {
            return degrees * Math.PI / 180;
        }
        const lat1 = toRadians(pointA.x);
        const lat2 = toRadians(pointB.x);
        const lon1 = toRadians(pointA.y);
        const lon2 = toRadians(pointB.y);
        const dLat = lat2 - lat1;
        const dLon = lon2 - lon1;
        const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
            Math.cos(lat1) * Math.cos(lat2) *
            Math.sin(dLon / 2) * Math.sin(dLon / 2);
        const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        const distance = radius * c;
        return distance;
    },
   
};
